package com.baizhi.service.impl;

import org.apache.ibatis.session.SqlSession;

import com.baizhi.dao.PageDao;
import com.baizhi.entity.Page;
import com.baizhi.service.PageService;
import com.baizhi.util.MyBatisUtils;

public class PageServiceImpl implements PageService {

	@Override
	public void insert(Page page) {
		SqlSession sqlSession = null;
		try {
			sqlSession = MyBatisUtils.getSqlSession();
			PageDao pd=sqlSession.getMapper(PageDao.class);
			pd.insert(page);
			sqlSession.commit();
		} catch (Exception e) {
			e.printStackTrace();
			sqlSession.rollback();
		}finally{
			MyBatisUtils.close(sqlSession);
		}
	}

	@Override
	public Page selectPageByPageno(int surveyId, int pageNo) {
		SqlSession sqlSession = null;
		Page page = null;
		try {
			sqlSession = MyBatisUtils.getSqlSession();
			PageDao pd=sqlSession.getMapper(PageDao.class);
			page = pd.selectPageByPageno(surveyId, pageNo);
			sqlSession.commit();
		} catch (Exception e) {
			e.printStackTrace();
			sqlSession.rollback();
		}finally{
			MyBatisUtils.close(sqlSession);
		}
		return page;
	}

}
